package com.dmcb.common.business.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;

import java.util.Locale;

/**
 * 消息处理服务
 * @author Jaken
 * @version 1.0
 *
 */
@Component
public class MessageMapper {

    private static final Locale locale = Locale.CHINA;

    @Autowired
    private MessageSource messageSource;

    /**
     * 获取普通消息
     * @param code
     * @return
     */
    public final String getMessage(String code) {
        return messageSource.getMessage(code, null, locale);
    }

    /**
     * 获取数字
     * @param code
     * @return
     */
    public final int getInt(String code) {
        return Integer.valueOf(getMessage(code));
    }

}

